home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 089a.dms / 089a.adf / EXAMPLE_PROGRAMS / example23.AMOS / example23.amosSourceCode
AMOS Source Code  |  1992-03-06  |  4KB  |  101 lines

  1. '==============
  2. 'Example23.Amos
  3. '==============
  4. Rem Guess the hidden word game.
  5.  
  6. Rem This is nowhere near a complete game, it's purpose it soley to demonstrate 
  7. Rem the use of the INSTR command explained fully in chapter 23.  
  8. Rem The major deficencies are that you cannot use words with more than 1 
  9. Rem identical letter, no scoring or limits to key presses it dosent check
  10. Rem if the same word is going to be used more than once etc. 
  11. Rem Why not see if you can add these features and more?
  12. '------------------------------------------------------------------------------
  13.  
  14. Curs Off : Hide : Paper 0
  15.  
  16. Rem DIMension an array called A$ to store some words in  
  17. Rem you can expand this easily simply by changing the 14, adding more  
  18. Rem text inside the data statements and the 14 in the for next loop.   
  19. '----------------------------------------------------------------------
  20. Dim A$(14)
  21. For A=1 To 14 : Read A$(A) : Next A
  22. Data "WARM","AMOS","RELATION","TUNIC","FATHER","BOLD","CRISPY"
  23. Data "QUICKEN","EXTRA","FINAL","DOPEY","WOVEN","HOME","STADIUM"
  24.  
  25. BEGIN:
  26.  
  27. Rem STORE$ will hold the previous guesses of the player
  28. Rem FOUND will be incremented each time a letter is found by player
  29. Rem when FOUND=the same length as the chossen word the word must of been found.
  30. '------------------------------------------------------------------------------
  31. Cls 0
  32. STORE$=""
  33. FOUND=0
  34.  
  35. Rem Pick on of the words from the data at random.
  36. Rem L will tell us the length of the chossen word for use later
  37. '--------------------------------------------------------------- 
  38. WORD=Rnd(13)+1
  39. L=Len(A$(WORD))
  40.  
  41. Rem Print the same amount of dashes as letters in the word to give player
  42. Rem a clue.
  43. '------------------------------------------------------------------------- 
  44. Pen 4 : Locate 0,3 : Print String$("-",L)
  45.  
  46. Home : Pen 5
  47. Under On : Centre "GUESS THE HIDDEN WORD" : Under Off 
  48.  
  49. Rem If you want to cheat unrem this line 
  50. '----------------------------------------
  51. 'locate 0,1:Print A$(WORD) 
  52.  
  53.  
  54. Rem Start of the main loop 
  55. '------------------------- 
  56. Do 
  57.  
  58.  
  59. Rem wait for a key press. Turn the keypress in to an upper case character. 
  60. '------------------------------------------------------------------------
  61. GKEY:
  62. K$="" : While K$="" : K$=Inkey$ : Wend 
  63. K$=Upper$(K$)
  64.  
  65. Rem check to see if key has already been used. If yes then goto keypress again 
  66. '--------------------------------------------------------------------------------
  67. X=Instr(STORE$,K$)
  68. If X<>0 Then Goto GKEY
  69.  
  70. Rem Now see if the selected letter is actually in the hidden word. 
  71. Rem If X is not zero then we have a match
  72. Rem if a match is found print that letter on the correct - mark. 
  73. Rem As we are using IF ENDIF this part will be skip if the IF is false.
  74. '------------------------------------------------------------------
  75. X=Instr(A$(WORD),K$)
  76. If X<>0
  77. Pen 6 : Locate X-1,3 : Print K$
  78. Inc FOUND
  79. End If 
  80.  
  81. Rem Remember the key pressed by adding it to thestring Store$
  82. Rem and print store$ on screen so user can see.
  83. '------------------------------------------------------------- 
  84. STORE$=STORE$+K$+","
  85. Pen 2 : Locate 0,20 : Print STORE$
  86.  
  87. Rem Another Endif jobbie, checks to see if the player has FOUUND all the 
  88. Rem letters in the word, if not the program jumps back to the beginning
  89. Rem of the Do Loop. If sucess then print a message,wait for a key press
  90. Rem then go back to begin and start a new game.
  91. '----------------------------------------------------------------------- 
  92. '
  93. If FOUND=L
  94. Pen 3
  95. Locate 0,10 : Centre "WELL DONE, PRESS A KEY"
  96. Clear Key 
  97. Wait Key 
  98. Goto BEGIN
  99. End If 
  100.  
  101. Loop